package com.tongqin.distributed;

import java.lang.reflect.Proxy;

/**
 * @author yuantongqin
 * @date 2018/7/9 下午3:45
 *
 * 通过代理类去调用接口的方法
 */
public class RpcClientProxy {


    public <T> T createObject(Class<T> interfaceName, String host, int port) {
        return (T) Proxy.newProxyInstance(interfaceName.getClassLoader(),
                new Class[]{interfaceName}, new ClientInvocationHandler(host,port));
    }


}
